package com.zjq.hibernate.pojo;

import java.sql.Timestamp;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;

/**
 * User entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "user", catalog = "bank", uniqueConstraints = @UniqueConstraint(columnNames = "username"))
public class User implements java.io.Serializable {

	// Fields

	private Integer userid;
	private Bankcard bankcard;
	private String username;
	private String userpwd;
	private Integer level;
	private Timestamp creattime;
	private Set<Log> logsForShoukuanid = new HashSet<Log>(0);
	private Set<Log> logsForFukuanid = new HashSet<Log>(0);

	// Constructors

	/** default constructor */
	public User() {
	}

	/** minimal constructor */
	public User(String username, String userpwd) {
		this.username = username;
		this.userpwd = userpwd;
	}

	/** full constructor */
	public User(Bankcard bankcard, String username, String userpwd,
			Integer level, Timestamp creattime, Set<Log> logsForShoukuanid,
			Set<Log> logsForFukuanid) {
		this.bankcard = bankcard;
		this.username = username;
		this.userpwd = userpwd;
		this.level = level;
		this.creattime = creattime;
		this.logsForShoukuanid = logsForShoukuanid;
		this.logsForFukuanid = logsForFukuanid;
	}

	// Property accessors
	@Id
	@GeneratedValue
	@Column(name = "userid", unique = true, nullable = false)
	public Integer getUserid() {
		return this.userid;
	}

	public void setUserid(Integer userid) {
		this.userid = userid;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "cardid")
	public Bankcard getBankcard() {
		return this.bankcard;
	}

	public void setBankcard(Bankcard bankcard) {
		this.bankcard = bankcard;
	}

	@Column(name = "username", unique = true, nullable = false, length = 45)
	public String getUsername() {
		return this.username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	@Column(name = "userpwd", nullable = false, length = 45)
	public String getUserpwd() {
		return this.userpwd;
	}

	public void setUserpwd(String userpwd) {
		this.userpwd = userpwd;
	}

	@Column(name = "level")
	public Integer getLevel() {
		return this.level;
	}

	public void setLevel(Integer level) {
		this.level = level;
	}

	@Column(name = "creattime", length = 0)
	public Timestamp getCreattime() {
		return this.creattime;
	}

	public void setCreattime(Timestamp creattime) {
		this.creattime = creattime;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "userByShoukuanid")
	public Set<Log> getLogsForShoukuanid() {
		return this.logsForShoukuanid;
	}

	public void setLogsForShoukuanid(Set<Log> logsForShoukuanid) {
		this.logsForShoukuanid = logsForShoukuanid;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "userByFukuanid")
	public Set<Log> getLogsForFukuanid() {
		return this.logsForFukuanid;
	}

	public void setLogsForFukuanid(Set<Log> logsForFukuanid) {
		this.logsForFukuanid = logsForFukuanid;
	}

}